package it.unibo.android.location;
import it.unibo.location.ILocation;
import it.unibo.location.LocationDevice;

/**
 * @author ale
 * @version 1.0
 * @created 24-ott-2012 00:45:22
 */

public class AndroidGPSDevice extends LocationDevice {

	/*
	 * default starting position = Malta.
	 */
	private static final double START_LATITUDE = 35.75;
	private static final double START_LONGITUDE = 14.5;
	private static final double START_ALTITUDE = 0;
	ILocation currentLocation;
	ILocation previousLocation;

	public AndroidGPSDevice() 
	{
		super();
		currentLocation = createLocation(START_LATITUDE, START_LONGITUDE, START_ALTITUDE);
		previousLocation = currentLocation;
	}

	@Override
	public ILocation getCurrentLocation() {
		return currentLocation;
	}

	/*
	 * m/s 
	 */
	@Override
	public float getSpeed() {
		return currentLocation.distanceTo(previousLocation)/((float)(currentLocation.getSampleTime()-previousLocation.getSampleTime()));

	}

	@Override
	public float getBearing() {
		return 0;
	}

	@Override
	public String getName() {
		return "JavaLocationDevice";
	}

	@Override
	public ILocation createLocation(double latitude, double longitude, double altitude) 
	{
		return new AndroidLocation(latitude,longitude,altitude);
	}

}